package cn.tang.tframe.sdm.validation;

import cn.tang.tframe.common.enums.BaseNumEnum;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Created by tanghc on 17/1/25.
 */
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {IsIntEnumValidator.class})
public @interface IsIntEnum {
	String message() default "{javax.validation.constraints.IsIntEnum.message}";

	Class<?>[] groups() default { };

	Class<? extends Payload>[] payload() default { };

	/**
	 * @return value of enum element int value
	 */
	int value() default 0;

	/**
	 * @return int enum class
	 */
	Class<? extends Enum<? extends BaseNumEnum> > clazz();

	/**
	 * Defines several {@link IsIntEnum} annotations on the same element.
	 *
	 */
	@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
	@Retention(RUNTIME)
	@Documented
	@interface List {

		IsIntEnum[] value();
	}
}
